package com.tank.demo.chainOfResponsibility;

import com.tank.demo.abstractFactory.BaseBullet;
import com.tank.demo.abstractFactory.BaseGameObject;
import com.tank.demo.abstractFactory.BaseTank;
import com.tank.demo.utils.RectangleUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.awt.*;


public class TankAndTankCollider implements Collider {
    @Override
    public boolean collide(BaseGameObject o1, BaseGameObject o2) {
        if (o1 instanceof BaseTank && o2 instanceof BaseTank) {
            if (RectangleUtil.intersects(o1, o2)) {
                ((BaseTank) o1).goBack();
                ((BaseTank) o2).goBack();
            }
            return true;
        }
        return false;
    }
}
